﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace SHomeWorkshop.LunarSF.StudentInfosManager.Converters
{
    /// <summary>
    /// 在民族名称与对应的索引值之间进行转换。
    /// </summary>
    [ValueConversion(typeof(string), typeof(int))]
    public class NationConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            switch (value.ToString())
            {
                case "汉族": return 0;
                case "蒙古族": return 1;
                case "回族": return 2;
                case "藏族": return 3;
                case "维吾尔族": return 4;
                case "苗族": return 5;
                case "彝族": return 6;
                case "壮族": return 7;
                case "布依族": return 8;
                case "朝鲜族": return 9;
                case "满族": return 10;
                case "侗族": return 11;
                case "瑶族": return 12;
                case "白族": return 13;
                case "土家族": return 14;
                case "哈尼族": return 15;
                case "哈萨克族": return 16;
                case "傣族": return 17;
                case "黎族": return 18;
                case "傈僳族": return 19;
                case "佤族": return 20;
                case "畲族": return 21;
                case "高山族": return 22;
                case "拉祜族": return 23;
                case "水族": return 24;
                case "东乡族": return 25;
                case "纳西族": return 26;
                case "景颇族": return 27;
                case "柯尔克孜族": return 28;
                case "土族": return 29;
                case "达斡尔族": return 30;
                case "仫佬族": return 31;
                case "羌族": return 32;
                case "布朗族": return 33;
                case "撒拉族": return 34;
                case "毛难族": return 35;
                case "仡佬族": return 36;
                case "锡伯族": return 37;
                case "阿昌族": return 38;
                case "普米族": return 39;
                case "塔吉克族": return 40;
                case "怒族": return 41;
                case "乌孜别克族": return 42;
                case "俄罗斯族": return 43;
                case "鄂温克族": return 44;
                case "崩龙族": return 45;
                case "保安族": return 46;
                case "裕固族": return 47;
                case "京族": return 48;
                case "塔塔尔族": return 49;
                case "独龙族": return 50;
                case "鄂伦春族": return 51;
                case "赫哲族": return 52;
                case "门巴族": return 53;
                case "珞巴族": return 54;
                case "基诺族": return 55;
                case "其他": return 56;
                case "外国血统": return 57;
            }

            return -1;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int)
            {
                switch ((int)value)
                {
                    case 0: return "汉族";
                    case 1: return "蒙古族";
                    case 2: return "回族";
                    case 3: return "藏族";
                    case 4: return "维吾尔族";
                    case 5: return "苗族";
                    case 6: return "彝族";
                    case 7: return "壮族";
                    case 8: return "布依族";
                    case 9: return "朝鲜族";
                    case 10: return "满族";
                    case 11: return "侗族";
                    case 12: return "瑶族";
                    case 13: return "白族";
                    case 14: return "土家族";
                    case 15: return "哈尼族";
                    case 16: return "哈萨克族";
                    case 17: return "傣族";
                    case 18: return "黎族";
                    case 19: return "傈僳族";
                    case 20: return "佤族";
                    case 21: return "畲族";
                    case 22: return "高山族";
                    case 23: return "拉祜族";
                    case 24: return "水族";
                    case 25: return "东乡族";
                    case 26: return "纳西族";
                    case 27: return "景颇族";
                    case 28: return "柯尔克孜族";
                    case 29: return "土族";
                    case 30: return "达斡尔族";
                    case 31: return "仫佬族";
                    case 32: return "羌族";
                    case 33: return "布朗族";
                    case 34: return "撒拉族";
                    case 35: return "毛难族";
                    case 36: return "仡佬族";
                    case 37: return "锡伯族";
                    case 38: return "阿昌族";
                    case 39: return "普米族";
                    case 40: return "塔吉克族";
                    case 41: return "怒族";
                    case 42: return "乌孜别克族";
                    case 43: return "俄罗斯族";
                    case 44: return "鄂温克族";
                    case 45: return "崩龙族";
                    case 46: return "保安族";
                    case 47: return "裕固族";
                    case 48: return "京族";
                    case 49: return "塔塔尔族";
                    case 50: return "独龙族";
                    case 51: return "鄂伦春族";
                    case 52: return "赫哲族";
                    case 53: return "门巴族";
                    case 54: return "珞巴族";
                    case 55: return "基诺族";
                    case 56: return "其他";
                    case 57: return "外国血统";
                }
            }

            return "";
        }

        private static NationConverter converter = new NationConverter();

        public static NationConverter Instance
        {
            get { return converter; }
        }
    }
}
